package com.kfm.base.net;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class TCPClient {

    public static void main(String[] args) {
//        try {
//            InetAddress byName = InetAddress.getByName(null);
//            System.out.println(byName);
//        } catch (UnknownHostException e) {
//            throw new RuntimeException(e);
//        }

        try(Socket client = new Socket(InetAddress.getLocalHost(), 8888);
            OutputStream outputStream = client.getOutputStream(); ) {

            outputStream.write("你好啊".getBytes());
            outputStream.write("你好啊1".getBytes());
            outputStream.write("你好啊2".getBytes());
            outputStream.write("你好啊3".getBytes());

            client.shutdownOutput();

            System.out.println("发送成功");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}


